/*
 * Filename: d:\idf_workspace\esp_face_id\main\src\app_camera.cc
 * Path: d:\idf_workspace\esp_face_id\main\src
 * Created Date: Friday, July 25th 2025, 11:40:40 am
 * Author: sss
 * 
 * Copyright (c) 2025 Your Company
 */

#include "app_camera.h"
#include "esp_log.h"
#include "esp_err.h"
#include "esp_camera.h"
#include "who_camera.h"

static const char* TAG = "AppCamera";



AppCamera::AppCamera(QueueHandle_t out_queue):out_queue(out_queue){}

AppCamera::~AppCamera(){
    out_queue = nullptr;
}

// static void task(void* arg)
// {
//     AppCamera* app_camera = (AppCamera*)arg;
//     while (true)
//     {
//         if(app_camera->out_queue == nullptr)break;
//         camera_fb_t* fb = esp_camera_fb_get();
//         if (!fb) {
//             ESP_LOGE(TAG, "Camera capture failed");
//             vTaskDelay(pdMS_TO_TICKS(1000));//1s
//             continue;
//         }
//         xQueueSend(app_camera->out_queue, &fb, portMAX_DELAY);
//     }
    
// }

void AppCamera::start()
{
    // xTaskCreatePinnedToCore(task, "taks", 4096, this, 1, NULL, 0);
    register_camera(PIXFORMAT_RGB565, FRAMESIZE_QVGA,2,this->out_queue);
}